package com.orchid.forum.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.orchid.common.dao.IBaseDao;
import com.orchid.common.pagination.Page;
import com.orchid.common.pagination.PageUtil;
import com.orchid.common.service.impl.BaseService;
import com.orchid.forum.dao.CategoryDao;
import com.orchid.forum.domain.Category;
import com.orchid.forum.domain.CategoryQuery;
import com.orchid.forum.service.CategoryService;

/**
 * User: Zhang Kaitao
 * Date: 12-1-4 上午11:06
 * Version: 1.0
 */

@Service("CategoryService")
public class CategoryServiceImpl extends BaseService<Category, Integer> implements CategoryService {

    private static final Logger LOGGER = LoggerFactory.getLogger(CategoryServiceImpl.class);

    private CategoryDao categoryDao;

    @Autowired
    @Qualifier("CategoryDao")
    @Override
    public void setBaseDao(IBaseDao<Category, Integer> categoryDao) {
        this.baseDao = categoryDao;
        this.categoryDao = (CategoryDao) categoryDao;
    }
    
    @Override
    public Page<Category> query(int pn, int pageSize, CategoryQuery command) {
        return PageUtil.getPage(categoryDao.countQuery(command) ,pn, categoryDao.query(pn, pageSize, command), pageSize);
    }

   
}